/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.unesp.demac.bcc.soo.clarus.ws;

import br.unesp.demac.bcc.soo.clarus.bean.Aluno;
import br.unesp.demac.bcc.soo.clarus.bean.Emprestimo;
import br.unesp.demac.bcc.soo.clarus.dao.AlunoDAO;
import br.unesp.demac.bcc.soo.clarus.dao.AlunoDAOImp;
import br.unesp.demac.bcc.soo.clarus.dao.EmprestimoDAO;
import br.unesp.demac.bcc.soo.clarus.dao.EmprestimoDAOImp;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
 *
 * @author esaheki
 */
@WebService(serviceName = "ClarusService")
public class ClarusService {

    /**
     * Web service operation
     */
    @WebMethod(operationName = "alunoLogin")
    public Aluno login(@WebParam(name = "user")
    String user, @WebParam(name = "pass")
    String pass) {
        AlunoDAO adao = new AlunoDAOImp();
        Aluno aluno = null;
        try {
            aluno = adao.validaAluno(user, pass);
        } catch (SQLException ex) {
            System.out.println("Erro ao validar aluno");
        }
        return aluno;
    }

    /**
     * Web service operation
     */
    @WebMethod(operationName = "getHistorico")
    public ArrayList getHistorico(@WebParam(name = "aluno")
    Aluno aluno) {
        ArrayList result = new ArrayList();
        EmprestimoDAO edao = new EmprestimoDAOImp();
        for (Emprestimo e : edao.getHistorico(aluno)) {
            result.add(e);
        }
        return result;
    }
}
